package com.briup.jz.web.controller;

import java.util.List;

import javax.validation.constraints.NotNull;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.briup.jz.bean.AccountSystem;
import com.briup.jz.service.IAccountSystemService;
import com.briup.jz.utils.Message;
import com.briup.jz.utils.MessageUtil;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;

@RestController
@RequestMapping("/system")
@Api(description = "管理员账户管理接口")
public class AccountSystemController {
    @Autowired
    private IAccountSystemService accountSystemService;

    @ApiOperation("查询所有系统操作")
    @GetMapping("query")
    public Message query(Double transfer_money, String type, String status) {
        List<AccountSystem> list = accountSystemService.query(transfer_money, type, status);
        return MessageUtil.success( list);
    }
    
    
    @ApiOperation("保存或更新管理员信息")
    @PostMapping ("saveOrUpdate")
    public Message saveOrUpdate(AccountSystem accountSystem) throws Exception {
        accountSystemService.saveOrUpdate(accountSystem);
        return MessageUtil.success("更新成功");
    }

    @ApiOperation(value = "通过id删除管理员信息")
    @GetMapping("deleteById")
    @ApiImplicitParams({
        @ApiImplicitParam(name="id",value = "主键",paramType = "query", required=true),
    })
    public Message deleteById(@NotNull Long id){
        accountSystemService.deleteById(id);
        return MessageUtil.success("删除成功");
    }

}
